package com.ease.integration.message;

import java.io.Serializable;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlType;

import com.ease.common.util.JsonUtil;
import com.ease.integration.constant.TargetNamespace;

@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "", propOrder = { "errorCode", "errorMessage" }, namespace = TargetNamespace.NAMESPACE)
@XmlRootElement(name = "serviceFault")
public class ServiceFault implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 5496767731338477901L;

	@XmlElement(name = "errorCode", required = true)
	private String errorCode = "UNKNOWN";

	@XmlElement(name = "errorMessage", required = true)
	private String errorMessage = "UNKNOWN";

	public ServiceFault() {
		super();
	}

	public ServiceFault(String errorCode) {
		this();
		this.setErrorCode(errorCode);
	}

	public ServiceFault(String errorCode, String errorMessage) {
		this(errorCode);
		this.setErrorMessage(errorMessage);
	}

	public String toString() {
		return JsonUtil.marshal(this);
	}

	/**
	 * @return the errorCode
	 */
	public String getErrorCode() {
		return errorCode;
	}

	/**
	 * @param errorCode
	 *            the errorCode to set
	 */
	public void setErrorCode(String errorCode) {
		this.errorCode = errorCode;
	}

	/**
	 * @return the errorMessage
	 */
	public String getErrorMessage() {
		return errorMessage;
	}

	/**
	 * @param errorMessage
	 *            the errorMessage to set
	 */
	public void setErrorMessage(String errorMessage) {
		this.errorMessage = errorMessage;
	}

}